package org.iteam.bank.signed.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.iteam.bank.core.Constant;
import org.iteam.db.DbType;
import org.iteam.db.c3p0.DbC3p0PoolFactory;
import org.iteam.db.exception.DbException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BankServletContextListener implements ServletContextListener {
	private static final Logger LOGGER = LoggerFactory.getLogger(BankServletContextListener.class);

	// 应用停止
	public void contextDestroyed(ServletContextEvent contextEvent) {

	}

	// 应用启动
	public void contextInitialized(ServletContextEvent contextEvent) {
		// 初始化数据源
		try {
			DbC3p0PoolFactory.init(DbType.DEFAULT.getCode(), Constant.MYSQL_WEIXIN, Constant.MYSQL_PAY);
		} catch (DbException e) {
			LOGGER.error(e.getMessage(), e);
		}
	}

}
